<?php 
session_start();
if (isset($_SESSION['openid'])){
	include_once("../c/config.php");
	$mysqli = new mysqli($dbhost, $dbuser, $dbpwd, $dbName);
	if (!$mysqli->set_charset("utf8")) {printf("Error loading character set utf8: %s\n", $mysqliTwo->error);}
	
	$openid=$_SESSION['openid'];
	 
	
    $query=$mysqli->query("select id from users where openid='".$openid."' limit 0, 1");
	if($query->num_rows>0){
		$mysqli->query("insert into log(openid,createtime) values('".$openid."','".date("Y-m-d H:i:s")."') ");
		$query=$mysqli->query("select id from log where openid='".$openid."' order by id desc limit 0,1 ");
		$logInfo=$query->fetch_array();
		$logId=$logInfo['id'];
		if ($logId>2000){
		    echo json_encode(array('status'=>'lost'));
		    exit;
		}else{
		    $query=$mysqli->query("select name from j where id='".$logId."' limit 0, 1");
		    if($query->num_rows>0){
		        $jInfo=$query->fetch_array();
		        echo json_encode(array('status'=>'yes','c'=>$jInfo['name']));
		    }else{
		        
		        echo json_encode(array('status'=>'lost'));
		        exit;
		    }
		    
		}
	 
	}else{
	    echo json_encode(array('status'=>'lost'));
	    exit;
	}
}


?>